package com.example.mybatislogdemo;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author zwy
 * @version 1.0
 * @description: DemoRunner
 * @date 2025/7/27 11:22
 */
@Component
@Slf4j
public class DemoRunner implements CommandLineRunner {

    @Resource
    private UserMapper userMapper;

    @Override
    public void run(String... args) throws Exception {
        log.info("======> DemoRunner 开始执行数据库查询...");

        // 场景一：传入简单参数，触发BaseMapper方法
        log.info("\n======> 开始测试场景一：简单参数");
        userMapper.selectById(1L);

        // 场景二：传入复杂对象参数，触发自定义XML方法
        log.info("\n======> 开始测试场景二：复杂参数");
        userMapper.findByNameAndAge("Tom", 25);

        log.info("======> DemoRunner 执行完毕！");
    }
}